package com.hulk.dryad.manage.provider.transaction;

import com.hulk.dryad.persistence.entity.CustomerLoginInfo;
import com.hulk.dryad.persistence.entity.CustomerOperator;

import com.hulk.dryad.manage.provider.service.impl.CustomerLoginInfoServiceImpl;
import com.hulk.dryad.manage.provider.service.impl.CustomerOperatorServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author  lqx
 * @date 2020/10/20
 * 2020/10/13
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class CustomerTransaction {

    private final CustomerLoginInfoServiceImpl customerLoginInfoServiceImpl;
    private final CustomerOperatorServiceImpl customerOperatorServiceImpl;


    @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void insertCustomerRelates(String workId, CustomerLoginInfo customerLogin, CustomerOperator customerOperator) {
        if (null != customerLogin) {
			customerLoginInfoServiceImpl.save(customerLogin);
        }

        if (null != customerOperator) {
			customerOperatorServiceImpl.save(customerOperator);
        }
        log.info("workId:{} Method:insertCustomerRelates 客户相关信息持久化完成!", workId);
    }


}
